package com.cloudcc.mobile.util;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.cloudcc.mobile.manager.RunTimeManager;
import com.cloudcc.mobile.manager.UserManager;
import com.cloudcc.mobile.view.main.MainCustomActivity;
import com.cloudcc.mobile.view.main.MainUIActivity;
import com.mypage.view.activity.PromptUserActivity;
import com.mypage.view.activity.ValidationActivity;

/**
 * @Description: 执行页面切换等
 * @author wangzhiqiang
 * @date 2015-12-28 上午10:47:01
 *
 */
public class UIUtils {

	/**
	 * 进入主页 如果从 登录页面进入 formtype ==1
	 */
	public static void enterMainUI(Context context, int formType) {
		Intent intent = new Intent(context, MainUIActivity.class);
		intent.putExtra("activity.from", formType);
		intent.putExtra("froms",formType);
		context.startActivity(intent);
	}
	/**
	 * 进入主页 默认是2
	 *
	 * @param context
	 */
	public static void enterMainUI(Context context) {
		if (TextUtils.isEmpty(UserManager.getManager().getUser().appMainPage)) {
			boolean IsUsingGotpFlag = RunTimeManager.getInstance().getIsUsingGotpFlag();
			boolean IsBoundMfa = RunTimeManager.getInstance().getIsBoundMfa();
			if (IsUsingGotpFlag) {
				if (IsBoundMfa) {
					Intent intent = new Intent(context, ValidationActivity.class);
					context.startActivity(intent);
				}else{
//					请打开洋葱客户端扫描PC绑定账号
					Intent intent = new Intent(context, PromptUserActivity.class);
					context.startActivity(intent);
				}
			}else{
				Intent intent = new Intent(context, MainUIActivity.class);
				intent.putExtra("activity.from", 2);
				context.startActivity(intent);
			}

		} else {
			Intent intent = new Intent(context, MainCustomActivity.class);
			intent.putExtra("from.type", 2);
			context.startActivity(intent);
		}
	}
}
